SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.[DnnProduct_CDS_DefaultStampConfigTemplateList]
	@DefaultStampConfigID int,
	@DRMType varchar(20)
AS
BEGIN
	IF (coalesce(@DRMType, 'Stamp') = 'Stamp')
	BEGIN
		SELECT T.[ID], [DistributorID], [Name], [Description], [Default], [Type] FROM dbo.[DnnProduct_CDS_Templates] T
		INNER JOIN [DnnProduct_CDS_StampSets] SS ON SS.[TemplateID] = T.[ID] AND SS.[DefaultStampConfigID] = @DefaultStampConfigID
		ORDER BY T.[Name] ASC
	END
	ELSE
	BEGIN
		SELECT T.[ID], [DistributorID], [Name], [Description], [Default], [Type] FROM dbo.[DnnProduct_CDS_Templates] T
		INNER JOIN [DnnProduct_CDS_StampSets] SS ON SS.[TemplateID] = T.[ID] AND SS.[DefaultDRMStampConfigID] = @DefaultStampConfigID AND T.[Type] = @DRMType
		ORDER BY T.[Name] ASC
	END
END
GO
